import httpInstant from '../utils/http';


/**
 * @description 获取用户信息
 * @param userId 用户id
 * @returns
 */
export const getUserInfoApi = (userId) => {

  return httpInstant.get('/userInfo/getUserInfo', {
    params: {
      userId
    }
  })
}


/**
 * @description 获取用户最后更新用户名日期
 * @param userId 用户id
 * @returns
 */
export const getUserLastUpdateUserNameDateApi = (userId) => {
  return httpInstant.get('/userInfo/getUserLastUpdateUserNameDate', {
    params: {
      userId
    }
  })
}


/**
 * @description 更新用户名
 * @param userId 用户id
 * @param newUserName 新的用户名
 * @returns
 */
export const updateUserNameApi = (userId, newUserName) => {
  console.log(newUserName);

  return httpInstant.put('/userInfo/updateUserName', {
    userId,
    newUserName
  })
}


export const updateGenderApi = (userId, newGender) => {
  return httpInstant.put('/userInfo/updateGender', {
    userId,
    newGender
  })
}


/**
 * @description 更新签名
 * @param userId 用户id
 * @param newSignature 新的签名
 * @returns
 */
export const updateSignatureApi = (userId, newSignature) => {
  return httpInstant.put('/userInfo/updateSignature', {
    userId,
    newSignature
  })
}



/**
 * @description 更新是否公开个人帖子
 * @param userId 用户id
 * @param isPublicPost 是否公开个人帖子
 * @returns
 */
export const updateIsPublicPostApi = (userId, isPublicPost) => {
  return httpInstant.put('/userInfo/updateIsPublicPost', {
    userId,
    isPublicPost
  })
}


/**
 * @description 更新是否公开个人帖子
 * @param userId 用户id
 * @param isPublicCollection 是否公开个人收藏
 * @returns
 */
export const updateIsPublicCollectionApi = (userId, isPublicCollection) => {
  return httpInstant.put('/userInfo/updateIsPublicCollection', {
    userId,
    isPublicCollection
  })
}


/**
 * @description 更新头像
 * @param userId 用户id
 * @param newAvatarUrl 新的头像url
 * @returns
 */
export const updateUserAvatarApi = (formData) => {

  return httpInstant.post('/common/upload', formData, {

    Headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

/**
 * @description 升级
 * @param userId 用户id
 * @param experience 经验值
 * @returns
 */

export const upgrade = (userId, experience) => {

  return httpInstant.put('/userInfo/upgrade', {
    userId,
    experience
  })
}